home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / perl5 / Term::ReadLine.z / Term::ReadLine
Encoding:
Text File  |  2002-10-03  |  7.3 KB  |  199 lines

  1.  
  2.  
  3.  
  4. TTTTeeeerrrrmmmm::::::::RRRReeeeaaaaddddLLLLiiiinnnneeee((((3333))))                                            TTTTeeeerrrrmmmm::::::::RRRReeeeaaaaddddLLLLiiiinnnneeee((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Term::ReadLine - Perl interface to various readline packages. If no real
  10.      package is found, substitutes stubs instead of basic functions.
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.        use Term::ReadLine;
  14.        $term = new Term::ReadLine 'Simple Perl calc';
  15.        $prompt = "Enter your arithmetic expression: ";
  16.        $OUT = $term->OUT || STDOUT;
  17.        while ( defined ($_ = $term->readline($prompt)) ) {
  18.          $res = eval($_), "\n";
  19.          warn $@ if $@;
  20.          print $OUT $res, "\n" unless $@;
  21.          $term->addhistory($_) if /\S/;
  22.        }
  23.  
  24.  
  25. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  26.      This package is just a front end to some other packages. At the moment
  27.      this description is written, the only such package is Term-ReadLine,
  28.      available on CPAN near you. The real target of this stub package is to
  29.      set up a common interface to whatever Readline emerges with time.
  30.  
  31. MMMMiiiinnnniiiimmmmaaaallll sssseeeetttt ooooffff ssssuuuuppppppppoooorrrrtttteeeedddd ffffuuuunnnnccccttttiiiioooonnnnssss
  32.      All the supported functions should be called as methods, i.e., either as
  33.  
  34.        $term = new Term::ReadLine 'name';
  35.  
  36.      or as
  37.  
  38.        $term->addhistory('row');
  39.  
  40.      where $term is a return value of Term::ReadLine->Init.
  41.  
  42.      ReadLine    returns the actual package that executes the commands. Among
  43.                  possible values are Term::ReadLine::Gnu,
  44.                  Term::ReadLine::Perl, Term::ReadLine::Stub Exporter.
  45.  
  46.      new         returns the handle for subsequent calls to following
  47.                  functions. Argument is the name of the application.
  48.                  Optionally can be followed by two arguments for IN and OUT
  49.                  filehandles. These arguments should be globs.
  50.  
  51.      readline    gets an input line, _p_o_s_s_i_b_l_y with actual readline support.
  52.                  Trailing newline is removed. Returns undef on EOF.
  53.  
  54.      addhistory  adds the line to the history of input, from where it can be
  55.                  used if the actual readline is present.
  56.  
  57.      IN, $OUT    return the filehandles for input and output or undef if
  58.                  readline input and output cannot be used for Perl.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTeeeerrrrmmmm::::::::RRRReeeeaaaaddddLLLLiiiinnnneeee((((3333))))                                            TTTTeeeerrrrmmmm::::::::RRRReeeeaaaaddddLLLLiiiinnnneeee((((3333))))
  71.  
  72.  
  73.  
  74.      MinLine     If argument is specified, it is an advice on minimal size of
  75.                  line to be included into history.  undef means do not include
  76.                  anything into history. Returns the old value.
  77.  
  78.      findConsole returns an array with two strings that give most appropriate
  79.                  names for files for input and output using conventions
  80.                  "<$in", ">out".
  81.  
  82.      Attribs     returns a reference to a hash which describes internal
  83.                  configuration of the package. Names of keys in this hash
  84.                  conform to standard conventions with the leading rl_
  85.                  stripped.
  86.  
  87.      Features    Returns a reference to a hash with keys being features
  88.                  present in current implementation. Several optional features
  89.                  are used in the minimal interface: appname should be present
  90.                  if the first argument to new is recognized, and minline
  91.                  should be present if MinLine method is not dummy.
  92.                  autohistory should be present if lines are put into history
  93.                  automatically (maybe subject to MinLine), and addhistory if
  94.                  addhistory method is not dummy.
  95.  
  96.                  If Features method reports a feature attribs as present, the
  97.                  method Attribs is not dummy.
  98.  
  99. AAAAddddddddiiiittttiiiioooonnnnaaaallll ssssuuuuppppppppoooorrrrtttteeeedddd ffffuuuunnnnccccttttiiiioooonnnnssss
  100.      Actually Term::ReadLine can use some other package, that will support
  101.      reacher set of commands.
  102.  
  103.      All these commands are callable via method interface and have names which
  104.      conform to standard conventions with the leading rl_ stripped.
  105.  
  106.      The stub package included with the perl distribution allows some
  107.      additional methods:
  108.  
  109.      tkRunning   makes Tk event loop run when waiting for user input (i.e.,
  110.                  during readline method).
  111.  
  112.      ornaments   makes the command line stand out by using termcap data.  The
  113.                  argument to ornaments should be 0, 1, or a string of a form
  114.                  "aa,bb,cc,dd".  Four components of this string should be
  115.                  names of _t_e_r_m_i_n_a_l _c_a_p_a_c_i_t_i_e_s, first two will be issued to
  116.                  make the prompt standout, last two to make the input line
  117.                  standout.
  118.  
  119.      newTTY      takes two arguments which are input filehandle and output
  120.                  filehandle.  Switches to use these filehandles.
  121.  
  122.      One can check whether the currently loaded ReadLine package supports
  123.      these methods by checking for corresponding Features.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. TTTTeeeerrrrmmmm::::::::RRRReeeeaaaaddddLLLLiiiinnnneeee((((3333))))                                            TTTTeeeerrrrmmmm::::::::RRRReeeeaaaaddddLLLLiiiinnnneeee((((3333))))
  137.  
  138.  
  139.  
  140. EEEEXXXXPPPPOOOORRRRTTTTSSSS
  141.      None
  142.  
  143. EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT
  144.      The envrironment variable PERL_RL governs which ReadLine clone is loaded.
  145.      If the value is false, a dummy interface is used. If the value is true,
  146.      it should be tail of the name of the package to use, such as Perl or Gnu.
  147.  
  148.      As a special case, if the value of this variable is space-separated, the
  149.      tail might be used to disable the ornaments by setting the tail to be o=0
  150.      or ornaments=0.  The head should be as described above, say
  151.  
  152.      If the variable is not set, or if the head of space-separated list is
  153.      empty, the best available package is loaded.
  154.  
  155.        export "PERL_RL=Perl o=0"     # Use Perl ReadLine without ornaments
  156.        export "PERL_RL= o=0"         # Use best available ReadLine without ornaments
  157.  
  158.      (Note that processing of PERL_RL for ornaments is in the discretion of
  159.      the particular used Term::ReadLine::* package).
  160.  
  161.      no real package is found, substitutes stubs instead of basic functions."
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.